package com.zhoukx.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @ClassName InfoColleageIterator
 * @Description:
 * @Author zhoukx
 * @Date 2020/8/17
 **/
public class InfoColleageIterator  implements Iterator {

    // 信息工程学院是以List方式存放
    List<Department> departments;
    // 索引
    int index = -1;

    public InfoColleageIterator(List<Department> departments) {
        this.departments = departments;
    }

    // 判断有没有下一个元素
    @Override
    public boolean hasNext() {
        if (index >= departments.size() -1) {
            return  false;
        }else {
            index += 1;
            return true;
        }
    }

    @Override
    public Object next() {
        return departments.get(index);
    }

    // 空实现
    @Override
    public void remove() {

    }
}
